package com.suitsoft.ut.service.base;

import java.util.Date;
import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springside.modules.orm.Page;

import com.suitsoft.ut.commons.UserHolder;
import com.suitsoft.ut.dao.account.UserDao;
import com.suitsoft.ut.dao.base.TeamDao;
import com.suitsoft.ut.entity.account.User;
import com.suitsoft.ut.entity.base.Team;

/**
 * 分组管理 服务层类
 *@author Suineg
 */
@Service
@Transactional
public class GroupManager {
	/** 日志输出对象 */
	protected final Logger logger = LoggerFactory.getLogger(getClass());
	
	@Autowired
	private TeamDao dao;
	@Autowired
	private UserDao userDao;
	
	private User user;
	
	public Team get(Long id){
		return dao.get(id);
	}
	
	public void save(Team team){
		user = userDao.get(UserHolder.getLoginUser().getId());
		team.setLastUser(user);
		team.setLastDate(new Date());
		dao.save(team);
	}
	
	public void delete(Long id){
		dao.delete(id);
	}
	
	public List<Team> getAll(){
		return dao.getAll();
	}
	
	public void getAllByPage(Page<Team> page){
		dao.getAll(page);
	}
	
	public Page<Team> findAllByCollege(Page<Team> page,String colldeCode){
		
		return dao.findAllByCollege(page, colldeCode);
	}
	
	public List<Team> findAllByCollege(String colldeCode){
		return dao.findAllByCollege(colldeCode);
	}
}

